{include file="pub:header" /}
<link rel='stylesheet' type='text/css' href='__PLUGIN__/ztree/css/zTreeStyle/zTreeStyle.css'>
<script language="JavaScript" charset="utf-8" type="text/javascript" src="__PLUGIN__/ztree/js/jquery.ztree.core-3.5.js"></script>
<script language="JavaScript" charset="utf-8" type="text/javascript" src="__PLUGIN__/ztree/js/jquery.ztree.excheck-3.5.js"></script>
<script type="text/javascript">
var setting = {
    check:{
        enable:true,
        chkboxType : { "Y" : "ps", "N" : "ps" }
    },
    data:{
        simpleData:{
            enable:true
        }
    }
};
var settin = {
    check:{
        enable:true,
        chkboxType : { "Y" : "ps", "N" : "ps" }
    },
    data:{
        simpleData:{
            enable:true
        }
    },
};

var zNodes =[
   {volist name="list" id="vo" key="k"}
   <?php
	   $checked = '';
	   if(in_array($vo['id'],$ids)){
		  $checked = ',checked:true' ;
	   }
    ?>
	{id:{$vo.id}, pId:{$vo.pid}, name:"{$vo.title}", open:{lt name="k" value="20"}true{else/}false{/lt}{$checked}} <?php echo $k==($menulen)?'':','; ?>
   {/volist}
];

//栏目节点
var column =[
        {volist name="colary" id="co" key="ke"}
        <?php
            $checked = '';
            if(in_array($co['id'],$cids)){
                $checked = ',checked:true' ;
            }
        ?>
{id:{$co.id}, pId:{$co.pid}, name:"{$co.title}", open:{lt name="ke" value="13"}true{else/}false{/lt}{$checked}}<?php echo $ke==($collen)?'':','; ?>
{/volist}
];

$(document).ready(function(){
	$.fn.zTree.init($("#treeDemo"), setting, zNodes);
    $.fn.zTree.init($("#column"), settin, column);
});

function dosubmit() {
    var zTree = $.fn.zTree.getZTreeObj("treeDemo");
    nodes = zTree.getCheckedNodes(true);
    var Zcolumn = $.fn.zTree.getZTreeObj("column");
    colus = Zcolumn.getCheckedNodes(true);

	var ids = "";
    var cids="";
	for (var i=0, l=nodes.length; i<l; i++) {
		ids += (0<i?",":"") +nodes[i].id ;
	}
    for (var i=0, l=colus.length; i<l; i++) {
        cids += (0<i?",":"") +colus[i].id ;
    }

	$("#ids").val(ids);
    $("#cids").val(cids);
	ajaxpost('form1');
}
//-->
</script>
<style>
.left_block {
    display: block;
    margin-right: 8px;
    padding: 8px;
    position: relative;
	width:60%;
}
.right_block{
	float:left;
}
</style>
</head>
<body>

<div class="subnav">
    <div class="content_menu ib_a blue line_x">
        <a href="javascript:;"><span class="pagetitle">【角色编辑】</span></a>
    </div>
</div>

<div class="pad_lr_10" >
 <div class="left_block fl">
	<form action="{:url('')}" method="post" id="form1">
	<input type="hidden" name="id" value="{$info['id']}" />
	<input type="hidden" name="ids" value="{$info['rules']}" id="ids" />
    <input type="hidden" name="cids" value="{$info['rules']}" id="cids" />
    <table width="100%" cellspacing="0" class="table_form">
        <tbody>
			<tr>
				<th width="16%"><font color="red">*</font> 权限组名称：</th>
				<td>
					<input name="title" type="text" value="{$info['title']}" class="input-text" size="30">
				</td>
			</tr>
			<tr>
			  <th>状态：</th>
			  <td>
			    <label><input type="radio" name="state" value="1" class="radio"<?php echo (!$info || 1==$info['state'])?' checked':'';?>>启用</label>&nbsp;&nbsp;
			    <label><input type="radio" name="state" value="0" class="radio"<?php echo (0===$info['state'])?' checked':'';?>>禁用</label>
			  </td>
			</tr>
			<tr>
			  <th>备注信息：</th>
			  <td>
			    <textarea name="description" class="input-text" style="width:500px;height:50px">{$info['description']}</textarea>
			  </td>
			</tr>

			<tr>
				<th width="120">&nbsp;</th>
                <td valign="bottom">
					<input class="smt  mr10" type="button" onclick="dosubmit();" value="<?php echo $info?'修改':'添加';?>" />&nbsp;&nbsp;
					<a class="smt" href="{:url('role')}">返回列表</a>
				</td>
			</tr>

        </tbody>
    </table>
    </form>
    </div>

    <div class="col_tab right_block">
	    <ul class="J_tabs tab_but cu_li" >
	        <li class="current" id="rd" onclick="rd('rd')">设置权限节点</li>
	        <li id="cod" onclick="cod('cod')" style="display: none;">设置栏目权限节点</li>
	    </ul>
		<div class="content_wrap">
			<div class="zTreeDemoBackground left">
				<ul id="treeDemo" class="ztree"></ul>
                   <ul id="column" class="ztree" style="display: none"></ul>
			</div>
           </div>
    </div>

</div>

{include file="pub:footer" /}
<script>
function rd(e){
    $("#"+e).addClass('current');
    $('#cod').removeClass('current');
    $('#treeDemo').show();
    $('#column').hide();
}
function cod(e){
    $("#"+e).addClass('current');
    $('#rd').removeClass('current');
    $('#column').show();
    $('#treeDemo').hide();
}
</script>
